package com.hits.zzbzstart.service;

import com.hits.zzbzstart.util.Decompression;
import org.springframework.stereotype.Service;

import java.io.File;

/**
 * @author wangshen
 * @ClassName AAA
 * @Description TODO
 * @date 2020/12/23
 */
@Service
public class InstallRedisService {

    public boolean install() {
        //读取redis免安装压缩包 解压缩到本地D根目录下
        //当前项目下路径
        File file = new File("");
        try {
            String filePath = file.getCanonicalPath();
            String targetPath = filePath + "\\src\\main\\resources\\static\\Redis-x64.zip";
            Decompression.unzip(targetPath, "D:\\redis");
            //使用进程执行cmd命令 启动redis
            Runtime.getRuntime().exec("C:/Windows/System32/cmd.exe /k start D:\\redis\\redis-server.exe");

            return true;

        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }


    }
}
